<script setup>

import ApplicationSettingModel from "@/model/ApplicationSettingModel.js";
import SettingService from "@/service/impl/SettingService.js"

const props = defineProps({
    application: {
        type: Object,
        default: () => new ApplicationSettingModel()
    }
})

const randomlyGenerated = () => {
    SettingService.randomKey(props.application).then(res => {
        props.application.key = res.data
    }).catch(e => {

    })
}

</script>

<template>
    <el-row style="width: 100%;">
        <!-- 左边 -->
        <el-col :span="11">
            <el-form-item label="通讯加密 (KEY)">
                <el-input v-model="application.key" style="width:70%;"/>
                <el-input v-model="application.keyLength" placeholder="KEY长度" style="width:15%; margin: auto"/>
                <el-button style="margin-left: auto;" @click="randomlyGenerated">随机生成</el-button>
            </el-form-item>
            <el-form-item label="是否开启通讯加密">
                <el-switch v-model="application.enable" :active-value="true" :inactive-value="false" class="ml-2"/>
            </el-form-item>
        </el-col>
        <el-col :span="1"></el-col>
        <!-- 右边 -->
        <el-col :span="12">
            <el-form-item label="通讯加密随机种子">
                <el-input v-model="application.seed"/>
            </el-form-item>
            <el-form-item label="操作日志保留时长 (天)">
                <el-input v-model="application.operationLogStored"/>
            </el-form-item>
        </el-col>
    </el-row>
</template>

<style scoped lang="scss">

</style>